<template>
  <div>
    <router-view></router-view>
    <div v-if="this.$route.name === '举报信息'">
      <div class="el">
        <!-- <el-button type="primary" @click="addUser">添加举报信息</el-button> -->
        <el-button type="text" @click="dealedMsg()"
          >查看已处理举报信息</el-button
        >
        <!-- <el-button type="text" @click="dealMsg()">查看未处理举报信息</el-button> -->
      </div>
      <el-table :data="list" style="width: 100%">
        <el-table-column prop="user_id" label="举报人id"> </el-table-column>
        <el-table-column prop="report_type_id" label="举报类型id">
        </el-table-column>
        <el-table-column prop="report_text" label="举报信息"> </el-table-column>
        <el-table-column prop="report_user_id" label="被举报人id">
        </el-table-column>
        <el-table-column prop="report_why" label="举报原因"> </el-table-column>
        <el-table-column prop="report_state" label="状态">
          <template slot-scope="scope">
            <span>{{
              scope.row.report_state === 0 ? '未处理' : '已处理'
            }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >处理</el-button
            >
            <!-- <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <!-- <el-dialog
      class="dialog"
      title="修改"
      :visible.sync="show"
      :show-close="false"
      :before-close="handleEdit"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="状态">
          <el-radio v-model="ruleForm.status" label="0">未处理</el-radio>
          <el-radio v-model="ruleForm.status" label="1">已处理</el-radio>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="escChange()">取消</el-button>
        <el-button @click="changeSuccess()" type="primary">修改</el-button>
      </div>
    </el-dialog> -->
    </div>
  </div>
</template>
<script>
import http from '../api/index';
export default {
  data() {
    var validateChangeMsg = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入内容'));
      } else {
        callback();
      }
    };
    var validateStatus = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请选择'));
      } else {
        callback();
      }
    };
    return {
      list: [],
      show: false,
    };
  },
  mounted() {
    http
      .informMsg({
        report_state: 0,
      })
      .then((r) => {
        console.log(r);
        this.list = r.data;
        console.log(this.list);
      });
  },
  methods: {
    addUser() {},
    //  已处理举报信息
    dealedMsg() {
      this.$router.push('/index/inform/massage/dealed');
    },
    
    handleEdit(index, row) {
      console.log(row.report_record_id);
      http
        .dealingMassage({
          report_record_id: row.report_record_id,
        })
        .then((r) => {
          console.log(r);
          this.$message({
            showClose: true,
            message: '处理成功',
            type: 'success',
          });
          http
            .informMsg({
              report_state: 0,
            })
            .then((r) => {
              console.log(r);
              this.list = r.data;
              console.log(this.list);
            });
        });
    },
  },
};
</script>
<style scoped>
.bnt1 {
  position: absolute;
}
.el {
  width: 100%;
  height: 40px;
  position: relative;
}
</style>